# models/sys_field_mapping.py
from sqlalchemy import Column, String, Date, DateTime, Boolean, Integer
from src.core.ormdb import Base
from src.core import str_utils as strU


class SysFieldMapping(Base):
    __tablename__ = 'sys_field_mapping'
    __table_args__ = {'comment': '字段匹配'}

    id = Column(String(36), primary_key=True, default=lambda: strU.generate_id(), comment="唯一标识ID")
    api_id = Column(String(36), nullable=True, comment='API主键')
    table_id = Column(String(36), nullable=True, comment='对应表匹配ID')
    field_name = Column(String(36), nullable=True, comment='字段名')
    field_title = Column(String(36), nullable=True, comment='字段标题')
    field_description = Column(String(36), nullable=True, comment='说明')
    mapping_field_name = Column(String(36), nullable=True, comment='字段名')

    deletion_mark = Column(Integer, default=0, comment='删除标志，0 表示未删除，1 表示已删除')
    deletion_reason = Column(String(255), nullable=True, comment='删除原因')
    deletion_date = Column(DateTime, nullable=True, comment='删除日期')
    deletion_by = Column(String(255), nullable=True, comment='删除者')
    create_date = Column(DateTime, default=lambda: strU.now(), comment='创建日期')
    creator_by = Column(String(255), nullable=True, comment='创建者')
    last_updated_date = Column(DateTime, nullable=True, comment='最后更新时间')
    last_updated_by = Column(String(255), nullable=True, comment='最后更新者')
